package com.pstreets.roboguice.demo;




import roboguice.activity.RoboActivity;
import roboguice.event.EventManager;
import roboguice.event.Observes;
import roboguice.inject.InjectView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import com.google.inject.Inject;

public class EventDemo extends RoboActivity {
    
    @Inject protected EventManager eventManager;
    @InjectView (R.id.button) Button button;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	 super.onCreate(savedInstanceState);
    	 setContentView(R.layout.eventdemo);
    	 button.setOnClickListener(mGoListener);
    }

    private OnClickListener mGoListener = new OnClickListener()
    {
        public void onClick(View v)
        {
        	 eventManager.fire(EventDemo.this,new MyEvent());
        }
    };
   
    
    protected void handleEvent(@Observes MyEvent event){
    	Toast.makeText(this, "Custom event", 
    			Toast.LENGTH_LONG).show();
    }
}


class MyEvent{
	//put any memeber you want here.
}
